package avicit.im.lantop.employeeshortcutkeys.service.api;


import avicit.im.lantop.employeeshortcutkeys.domain.EmployeeShortcutKeys;
import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.restclient.RestClient;
import avicit.platform6.core.restclient.RestClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class EmployeeshortcutServiceApi {



    /**
     * 服务编码
     */
    private static final String SERVICE_CODE = "filebasicmanager";

    private static final String BASE_PATH = "/api/avicit/im/lantop/employeeshortcutkeys/rest/EmployeeshortcutServiceRest";

    @Autowired
    private RestClient restClient;


    /**
     * 获得所有首页快捷键数据
     * @return
     */
    public List<Map<String, Object>> getEmpItem() {
        String url = BASE_PATH + "/getEmpItem";
        Map<String,Object> map = new HashMap<>();
        ResponseMsg<List<Map<String, Object>>> responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg<List<Map<String, Object>>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }


    /**
     * 根据Id获取对应的快捷键数据
     * @param id
     * @return
     */
    public EmployeeShortcutKeys getEmpItemById(String id) {
        String url = BASE_PATH + "/getEmpItemById";
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        ResponseMsg<EmployeeShortcutKeys> responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg<EmployeeShortcutKeys>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }


    /**
     *
     * @param em
     */
    public void updateEmpItemById(EmployeeShortcutKeys em) {
        String url = BASE_PATH + "/updateEmpItemById";
        Map<String,Object> map = new HashMap<>();
        map.put("em",em);
        ResponseMsg responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg<EmployeeShortcutKeys>>() {
        });
    }
}
